package goods_manage.show.MainTableView;



import javax.swing.*;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableColumn;
import java.awt.*;
import java.util.Vector;

public class MainViewTable extends JTable {

    public MainViewTable() {
        //设置表头
        JTableHeader jTableHeader = getTableHeader();
        jTableHeader.setFont(new Font(null, Font.BOLD, 18));
        jTableHeader.setForeground(Color.RED);
        //设置表格体
        setFont(new Font(null, Font.PLAIN, 16));
        setForeground(Color.BLACK);
        setGridColor(Color.black);
        setRowHeight(30);
        //设置多行选择
        getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
        //渲染表格列

    }

    public void RenderRule() {
        Vector<String> col = MainViewTableModel.getCol();
        MainViewCellRender mainViewCellRender = new MainViewCellRender();
        for (int i = 0; i < col.size(); i++) {
            TableColumn tableColumn = getColumn(col.get(i));
            tableColumn.setCellRenderer(mainViewCellRender);
            if (i == 0) {
                tableColumn.setPreferredWidth(50);
                tableColumn.setMaxWidth(50);
                tableColumn.setResizable(false);
            }
        }
    }
}
